<!DOCTYPE html>
<html lang="zh">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
	<style type="text/css">
		body, html, #allmap{
			width:100%;
			height:100%;
			overflow:hidden;
			margin:0;
			font-family:"微软雅黑", sans-serif;
		}
		#l-map{
			height:100%;
			width:78%;
			float:left;
			border-right:2px solid #bcbcbc;
		}
		#r-result{
			height:100%;
			width:20%;
			float:left;
		}
	</style>
	<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=h4UxXbr5o3e7dQXd1tYU4nTunX4sH9UM"></script>
	<title>添加多个标注点</title>
</head>
<body>
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
	// 百度地图API功能
	const map = new BMap.Map("allmap");
	let point = new BMap.Point(113.514,34.842);
	map.centerAndZoom(point,20);
	map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
	map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
	// 编写自定义函数,创建标注
	function addMarker(point){
		const marker = new BMap.Marker(point);
		map.addOverlay(marker);
	}
	// 随机向地图添加25个标注
	// const bounds = map.getBounds();
	// const sw = bounds.getSouthWest();
	// const ne = bounds.getNorthEast();
	// const lngSpan = Math.abs(sw.lng-ne.lng);
	// const latSpan = Math.abs(ne.lat-sw.lat);
	// for(let i = 0; i<25; i++){
	// let point = new BMap.Point(sw.lng+lngSpan*(Math.random()*0.7),ne.lat-latSpan*(Math.random()*0.7));
	// 		let point = new BMap.Point(113.514,34.842);
	// 	addMarker(point);
	// }
	addMarker(new BMap.Point(113.513161,34.843015));
	addMarker(new BMap.Point(113.514382,34.842552));
	addMarker(new BMap.Point(113.514139,34.842001));
	addMarker(new BMap.Point(113.512832,34.842444));
	addMarker(new BMap.Point(113.513016,34.842744));
	addMarker(new BMap.Point(113.513793,34.842789));
	addMarker(new BMap.Point(113.514278,34.842278));
	addMarker(new BMap.Point(113.513479,34.842231));
	addMarker(new BMap.Point(113.513317,34.8427));
</script>
